package com.oig.sys.workflow.dto;

import com.oig.common.validator.EnumValue;
import com.oig.common.validator.GroupAdd;
import com.oig.common.validator.GroupEdit;
import com.oig.sys.workflow.constants.FlowEnums;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import javax.validation.constraints.NotEmpty;
import java.util.List;

@Schema
@Getter
@Setter
@ToString
public class FlowFormDto {

	@Schema(description = "ID")
	private Integer id;

	@Schema(description = "流程配置id")
	private Integer flowConfigId;

	@Schema(description = "表单id", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
	@NotEmpty(message = "参数错误，表单id不能为空", groups= {GroupAdd.class, GroupEdit.class})
	private String fieldId;
	@Schema(description = "表单名称", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
	@NotEmpty(message = "参数错误，表单名称不能为空", groups= {GroupAdd.class, GroupEdit.class})
	private String fieldName;
	@Schema(description = "表单类型 对应枚举FormType", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
	@NotEmpty(message = "参数错误，表单类型不能为空", groups= {GroupAdd.class, GroupEdit.class})
	@EnumValue(message = "表单类型值不正确", enumClass = FlowEnums.FormType.class, enumValidMethod = "validCode", groups={GroupAdd.class, GroupEdit.class})
	private String fieldType;
	@Schema(description = "是否必填")
	private String required;
	@Schema(description = "默认值")
	private String defaultValue;

	@Schema(description = "备选项 json格式: [{\"value\":\"m82xbuhf-b0d0p09xk3h-0\",\"text\":\"公章\"}]")
	private String fieldOption;

	@Schema(description = "父表单项id 嵌套时有")
	private Integer parentId;

	@Schema(description = "fieldType=fieldList 时是表格，有子表单")
	private List<FlowFormDto> children;

}
